import http from "@/utils/http";
/**
 * 小程序登录
 * @param {string} encryptedData 加密的手机号信息 getphonenumber事件回调中获取
 * @param {string} iv 加密相关 getphonenumber事件回调中获取
 * @param {string} code 通过 wx.login() 获取
 */
export const postLoginWxMin = (data) => {
  return http({
    url: "/login/wxMin",
    method: "POST",
    data,
  });
};

/**
 * 小程序登录 - 测试
 * @param {string} phoneNumber 手机号
 */
export const postLoginWxMinSimple = (phoneNumber) => {
  return http({
    url: "/login/wxMin/simple",
    method: "POST",
    data: { phoneNumber },
  });
};

/**
 * 获取个人信息
 */
export const getMemberProfile = () => {
  return http({
    url: "/member/profile",
  });
};

/**
 * 修改头像
 * 原来网页开发中，请求，上传图片发送用的axios
 * 微信开发中 -
 * 请求 wx.request
 * 上传图片 wx.uploadFile
 */
export const postMemberProfileAvatar = (filePath) => {
  return uni.uploadFile({
    url: "/member/profile/avatar",
    filePath,
    name: "file",
  });
};

/**
 * 修改个人信息
 */
export const putMemberProfile = (data) => {
  return http({
    url: "/member/profile",
    method: "put",
    data,
  });
};
